
#include "S_27_AiContrrol_doGet.h"
#include "mi_iid_define.h"
#include "string.h"
#include "section_define.h"
#include "main.h"

extern uint8_t  g_uNo1RegList[PBS_NO1REGSIZE];

/**
 * 格式: property_value_new_string(字符串)　
 * 取值: 字符串，没有限制取值范围
 */
static void P_27_2_AiParam_doGet(property_operation_t *o)
{
	char Str[64] ={0};
	
	float Temp[7] = {0.0};
	uint16_t Data = 0;
//	if(g_uNo1RegList[0x4C])
	{
		Temp[0] = (float)((g_uNo1RegList[0x4E]<<8) | (g_uNo1RegList[0x4D]))/10.0;
		Temp[1] = (float)(((g_uNo1RegList[0x50]<<8) | g_uNo1RegList[0x4F]) -1000)/10.0;
		Temp[2] = (float)(((g_uNo1RegList[0x52]<<8) | g_uNo1RegList[0x51]) -1000)/10.0;
		Temp[3] = (float)(((g_uNo1RegList[0x55]<<8) | g_uNo1RegList[0x54]) -1000)/10.0;
		Temp[4] = (float)(((g_uNo1RegList[0x57]<<8) | g_uNo1RegList[0x56]) -1000)/10.0;
		Temp[5] = (float)(((g_uNo1RegList[0x59]<<8) | g_uNo1RegList[0x58]) -1000)/10.0;
		Temp[6] = (float)(((g_uNo1RegList[0x5C]<<8) | g_uNo1RegList[0x5B]))/10.0;
		Data = (g_uNo1RegList[0x5E]<<8) | g_uNo1RegList[0x5D];
		sprintf(Str,"%.1f,%.1f,%.1f,%d,%.1f,%.1f,%.1f,%d,%.1f,%d,%d",Temp[0],Temp[1],Temp[2],g_uNo1RegList[0x53],Temp[3],Temp[4],Temp[5],g_uNo1RegList[0x5A],Temp[6],Data,g_uNo1RegList[0x5F]);
		o->value.format = PROPERTY_FORMAT_STRING;
		strncpy(o->value.data.string.value, Str, strlen(Str)); // TODO: 这里需要读到属性真正的值
		o->value.data.string.length = strlen(Str); 
	}

}

void S_27_AiContrrol_doGet(property_operation_t *o)
{
    switch (o->piid)
    {
		case PIID_27_1_AiCompressorFreq:
            P_27_2_AiParam_doGet(o);
            break;
		
        case PIID_27_2_AiParam:
            P_27_2_AiParam_doGet(o);
            break;

        default:
            o->code = OPERATION_ERROR_VALUE;
            break;
    }
}
